(() => {
    class User {
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }
    }
    // 定义一个类， 可以针对用户的信息对象进行增删改查
    class UserCRUD {
        constructor() {
            this.data = [];
        }
        add(user) {
            user.id = Date.now() + Math.random();
            this.data.push(user);
            return user;
        }
        getUserId(id) {
            return this.data.find(user => user.id === id);
        }
    }
    // 实例化添加用户信息对象的类 UserCRUD
    const userCURD = new UserCRUD();
    userCURD.add(new User('jack', 20));
    userCURD.add(new User('jack', 20));
    const { id } = userCURD.add(new User('lucy', 21));
    console.log(userCURD.data);
    console.log(userCURD.getUserId(id));
    // 泛型类
    class GenericClass {
    }
    const g1 = new GenericClass();
    g1.defaultValue = 100;
    g1.add = function (x, y) {
        return x + y;
    };
    console.log(g1.add(g1.defaultValue, 20));
    const g2 = new GenericClass();
    g2.defaultValue = 'Hello';
    g2.add = function (x, y) {
        return x + y;
    };
    console.log(g2.add(g2.defaultValue, ' World'));
    function getLength(x) {
        return x.length;
    }
    console.log(getLength('what are you no sha lei'));
})();
